import { defineConfig } from 'vite'
import { resolve } from 'path'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      // 自动按需引入，公共方法命名以$开头
      imports: [
        'vue',
        { 'dayjs': [['*', '$dayjs']] },
        { '@/http/index.js': [['get', '$get'], ['post', '$post'], ['del', '$del'], ['upload', '$upload']], },
        { '@/assets/js/lodash.js': ['$debounce', '$throttle'], },
        { '@/assets/js/toast.js': [['*', '$toast']] }, // import { * as $toast } from '@/assets/utils/toast.js'
      ],
    }),
  ],
  // transpileDependencies: ['@dcloudio/uni-ui', 'uview-plus'],
  resolve: {
    alias: {
      '@': resolve('src'),
    },
  },
})
